<template>
  <div>
    <el-button text @click="addShow = true">添加分类</el-button>
    <el-dialog v-model="addShow" title="添加" width="30%">
      <el-input v-model="add_name" placeholder="Please input" />

      <br><br>

      <!-- <span v-for="(item,index) in classify_list" :key="index">
        <el-select-v2
          v-model="item.name"
          :options="options"
          placeholder="上级分类"
        />
      </span> -->

      <br /><br />

      <el-button type="primary" @click="add_classify">提交</el-button>
    </el-dialog>

    <table>
      <tr>
        <td>创建时间</td>
        <td>分类名称</td>
        <td>上级分类</td>
        <td>操作</td>
      </tr>
      <tr v-for="(item, index) in classify_list" :key="index">
        <td>{{ datetime(item.create_date) }}</td>
        <td>{{ item.name }}</td>
        <td>
          {{ item.classify }}
        </td>
        <td>
          <van-button
            type="default"
            @click="(nameShow = true), (id = item.id)"
            style="background: rgba(0, 0, 0, 0)"
            >修改</van-button
          >
          <van-button
            type="default"
            @click="del_school(item.id)"
            style="background: rgba(0, 0, 0, 0)"
            >删除</van-button
          >
        </td>
      </tr>
    </table>
  </div>
</template>

<script>
import { datetime } from "../utils/utils";
export default {
  data() {
    return {
      datetime,
      classify_name: "",
      classify_id: "",
      addShow: false,
      nameShow: false,
      classify_list: "",
      classifyShow: false,
      add_name: "",
    };
  },
  mounted() {
    this.classify_show();
  },
  methods: {
    classify_show: function () {
      this.myaxios(this.host + "study/classifys/", "get").then((data) => {
        console.log(data);
        if (data.code == 200) {
          this.$toast.success(data.msg);
          this.classify_list = data.data;
        } else {
          this.$toast.fail(data.msg);
        }
      });
    },
  },
};
</script>

<style>
</style>